#include <stdio.h>
#include <stdlib.h>

typedef struct Link *link;
typedef struct Link node;

struct Link
{
	int data;
	struct Link *next;
};

void hcreat(link head, int n)
{
	int j = 0;
	int x = 2;
	link rear = 0, prior = 0;
	head = (link)malloc(sizeof(link));
	// prior = head;
	// x = scanf("%d", x);
	while (j < n)
	{
		prior = (link)malloc(sizeof(link));
		j++;
		scanf("%d", &x);
		head->data = x;
		prior->next = head->next;
		prior = head;		
	}
	//head->next = '\0';
	//return prior;
}

node *creat_link()
{
	int c = 0;
	node *h =0, *s=0, *r= 0;
	h = (link)malloc(sizeof(node));
	r = h;
	//scanf("%d", &c);
	while (c != -1)
	{
		s = (link)malloc(sizeof(node));
		s->data = c;
		r->next = s;
		r = s;
		scanf("%d", &c);
	}
	r->next = '\0';
	return h;
}

void print(link head)
{
	link p = 0;
	p = head->next ;
	if (p  == '\0')
		printf("list null\n");
	else {
		while(p->next != '\0')
		{
			printf("%d\n", p->data);
			p = p->next;
		}
	}
}

void insert(link head, int x, int y)
{
	link  p = head->next;
	link  q = (link)malloc(sizeof(link));
	while ((p != '\0') && (p->data != y))
	{	p = (link)malloc(sizeof(link));
		p->data = x;
		q->next = p;
		q = p;
	}
}

void main()
{
	link head = 0;
	int n = 5; 
	//hcreat(head, n);	
	head = creat_link();
	print(head);
	insert(head, 44, 6);
	print(head);
}